package com.class5.springboot.util;

import java.io.UnsupportedEncodingException;

public final class Md5Util {

    private static final String DEFAULT_CHARSET = "UTF-8";

    private Md5Util() {}

    public static String md5Hex(String value, String charset) {
        try {
            return DigestUtils.md5Hex(value.getBytes(charset));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("MD5加密错误：",e);
        }
    }

    public static String md5Hex(String value) {
        return Md5Util.md5Hex(value, DEFAULT_CHARSET);
    }
}